//
//  WhzPDDSearchCategoryCell.m
//  WhzPinDuoDuo
//
//  Created by whz on 16/11/17.
//  Copyright © 2016年 whz. All rights reserved.
//

#import "WhzPDDSearchCategoryCell.h"
#import <Masonry.h>

@interface WhzPDDSearchCategoryCell ()

/**
 分类名称
 */
@property(nonatomic, strong)UILabel *labelNameCategory;
/**
 分类配图
 */
@property(nonatomic, strong)UIImageView *imageViewCategory;

@end

@implementation WhzPDDSearchCategoryCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}

#pragma mark - 初始化UI
/**
 初始化UI
 */
- (void)setupUI {
    
    CGFloat margin = 8;
    
    // MARK: - 分类名称
    self.labelNameCategory = [[UILabel alloc] init];
    self.labelNameCategory.text = @"名称";
    [self.contentView addSubview:self.labelNameCategory];
    [self.labelNameCategory mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(margin);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
    }];
    
    // MARK: - 分类配图
    self.imageViewCategory = [[UIImageView alloc] init];
    self.imageViewCategory.image = [UIImage imageNamed:@"tabBar_market"];
    self.imageViewCategory.highlightedImage = [UIImage imageNamed:@"tabBar_market_selected"];
    [self.contentView addSubview:self.imageViewCategory];
    [self.imageViewCategory mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.labelNameCategory.mas_right).offset(margin);
        make.centerY.mas_equalTo(self.labelNameCategory.mas_centerY);
        make.width.mas_equalTo(self.labelNameCategory.bounds.size.height);
        make.height.mas_equalTo(self.labelNameCategory.bounds.size.height);
    }];
}

/**
 重写set方法赋值
 
 @param indexPathForRow 行数据
 */
//- (void)setIndexPathForRow:(NSInteger)indexPathForRow {
//    
//    self.labelNameCategory.text = self.arrayRoot[indexPathForRow][@"opt_name"];
//}

- (void)setArrayRootModel:(NSArray<WhzPDDRootModel *> *)arrayRootModel {

    _arrayRootModel = arrayRootModel;
    
    self.labelNameCategory.text = arrayRootModel[self.indexPathForRow].opt_name;
    
}

@end
